package Forms;

import Classes.*;
import static Forms._UAdmin.mi;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author Owner
 */
public class CurrDetails1 extends javax.swing.JFrame {

    static MInterface mi;
    static User cUser;
    static String sss;
    static Curriculum curr;
    static ArrayList<SchoolYear> syList;
    static ArrayList<Curriculum> currList;
    DefaultTableModel currdtm;
    static ArrayList<ClassLevel> clevelList;
    ArrayList<Curriculum> selected = new ArrayList<Curriculum>();
    DefaultTableModel cleveldtm1;
    DefaultTableModel cleveldtm2;
    ArrayList<ClassLevel> cl1;
    ArrayList<ClassLevel> cl2 = new ArrayList<ClassLevel>();
    static ArrayList<ClassLevel> clevelsyList;
    static ArrayList<Subject> subjList;
    DefaultTableModel subjdtm1;
    DefaultTableModel subjdtm2;
    ArrayList<Subject> subj1;
    ArrayList<Subject> subj2 = new ArrayList<Subject>();
    static ArrayList<Sections> secList;
    DefaultTableModel secdtm1;
    DefaultTableModel secdtm2;
    ArrayList<Sections> sec1;
    ArrayList<Sections> sec2 = new ArrayList<Sections>();
    String currentSY = null;
    SchoolYear sy;
    String syID;

    /**
     * Creates new form Admin
     */
    public CurrDetails1(User user, MInterface i, String a, Curriculum b) {

        initComponents();
        this.setLocationRelativeTo(getRootPane());
        cUser = user;
        mi = i;
        sss = a;
        curr = b;
        try {
            timeL.setText(mi.getCurrentTime());
            dateL.setText(mi.getCurrentDate());
            usernameL.setText(cUser.getName());

            if (a.equals("open")) {
                p2.setEnabled(false);
                p3.setEnabled(false);
                p4.setEnabled(false);
                loadCurrSY("add");
                currdtm = new DefaultTableModel(new String[]{currTbl.getColumnName(0)}, 0);

                currList = (ArrayList<Curriculum>) mi.getList2("getlist2-curriculumopensy", syCB.getSelectedItem().toString().split("-")[0], "").clone();
                loadCurrCB();

            } else {
                loadCurrSY("view");

                sy = (SchoolYear) mi.get("get-sy", b.getCurrSY(), "");
                syCB.setSelectedItem(b.getCurrSY());
                syCB.setEnabled(false);
                startC.setEnabled(false);
                ((JTextField) startC.getDateEditor().getUiComponent()).setText(sy.getSyStart());
                endC.setEnabled(false);
                ((JTextField) endC.getDateEditor().getUiComponent()).setText(sy.getSyEnd());
                numdays.setEnabled(false);
                numdays.setText(sy.getNumOfDays() + "");
                compute.setEnabled(false);


                currList = (ArrayList<Curriculum>) mi.getList2("getlist2-currdetailscurriculum", b.getSyID(), "").clone();
                currdtm = new DefaultTableModel(new String[]{currTbl.getColumnName(0)}, 0);
                currTbl.setModel(currdtm);
                for (int x = 0; x < currList.size(); x++) {
                    currdtm.addRow(new Object[]{currList.get(x).getCurrName()});

                }
                
                load1b();
                load2b();
                load3b();

                add1.setEnabled(false);

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void compute() {
        int schoolDays = 0;
        Calendar st = Calendar.getInstance();
        Calendar en = Calendar.getInstance();

        Date s = startC.getDate();
        Date e = endC.getDate();

        st.setTime(s);
        en.setTime(e);

        do {
            st.add(Calendar.DAY_OF_MONTH, 1);
            if (st.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && st.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY && en.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && en.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
                schoolDays++;
            }
        } while (st.getTimeInMillis() < en.getTimeInMillis());
        numdays.setText(String.valueOf(schoolDays));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        dateL = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        timeL = new javax.swing.JLabel();
        usernameL = new javax.swing.JLabel();
        logoutB = new javax.swing.JButton();
        mainP = new javax.swing.JTabbedPane();
        p1 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        syCB = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        startC = new com.toedter.calendar.JDateChooser();
        endC = new com.toedter.calendar.JDateChooser();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        numdays = new javax.swing.JTextField();
        currCB = new javax.swing.JComboBox();
        jLabel88 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        currTbl = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        add1 = new javax.swing.JButton();
        save1 = new javax.swing.JButton();
        cancel1 = new javax.swing.JButton();
        compute = new javax.swing.JButton();
        remove1 = new javax.swing.JButton();
        p2 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        clevel1 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jLabel2 = new javax.swing.JLabel();
        label2a = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        currCB2 = new javax.swing.JComboBox();
        add2 = new javax.swing.JButton();
        remove2 = new javax.swing.JButton();
        addclevel = new javax.swing.JButton();
        save2 = new javax.swing.JButton();
        cancel2 = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        clevel2 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jLabel13 = new javax.swing.JLabel();
        label2b = new javax.swing.JLabel();
        p3 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        sub1 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jLabel25 = new javax.swing.JLabel();
        label4a = new javax.swing.JLabel();
        clevelCB3 = new javax.swing.JComboBox();
        jLabel40 = new javax.swing.JLabel();
        add3 = new javax.swing.JButton();
        remove3 = new javax.swing.JButton();
        addsubj = new javax.swing.JButton();
        save3 = new javax.swing.JButton();
        cancel3 = new javax.swing.JButton();
        jPanel15 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        sub2 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }
        };
        jLabel28 = new javax.swing.JLabel();
        label4b = new javax.swing.JLabel();
        p4 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        secT2 = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex){
                return false;
            }};
            jLabel22 = new javax.swing.JLabel();
            label5b = new javax.swing.JLabel();
            add4 = new javax.swing.JButton();
            remove4 = new javax.swing.JButton();
            jPanel8 = new javax.swing.JPanel();
            jScrollPane7 = new javax.swing.JScrollPane();
            secT1 = new javax.swing.JTable(){
                public boolean isCellEditable(int rowIndex, int colIndex){
                    return false;
                }};
                jLabel30 = new javax.swing.JLabel();
                label5a = new javax.swing.JLabel();
                clevelCB4 = new javax.swing.JComboBox();
                jLabel33 = new javax.swing.JLabel();
                addsection = new javax.swing.JButton();
                save4 = new javax.swing.JButton();
                cancel4 = new javax.swing.JButton();
                jSeparator2 = new javax.swing.JSeparator();

                setTitle("Curriculum Details");

                jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Resources/banner.jpg"))); // NOI18N
                jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

                dateL.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
                dateL.setText("mm/dd/yy");

                jSeparator1.setForeground(new java.awt.Color(0, 102, 51));

                timeL.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
                timeL.setText("hh:mm am/pm");

                usernameL.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
                usernameL.setText("username");

                logoutB.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                logoutB.setText("Logout");
                logoutB.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        logoutBActionPerformed(evt);
                    }
                });

                mainP.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
                mainP.addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseClicked(java.awt.event.MouseEvent evt) {
                        mainPMouseClicked(evt);
                    }
                    public void mouseEntered(java.awt.event.MouseEvent evt) {
                        mainPMouseEntered(evt);
                    }
                });

                jPanel11.setBackground(new java.awt.Color(255, 255, 255));
                jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

                syCB.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                syCB.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        syCBActionPerformed(evt);
                    }
                });

                jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
                jLabel4.setText("School Year:");

                jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
                jLabel5.setText("Start Date:");

                startC.setDateFormatString("yyyy-MM-dd");
                startC.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

                endC.setDateFormatString("yyyy-MM-dd");
                endC.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

                jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
                jLabel6.setText("End Date:");

                jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
                jLabel7.setText("Number of School Days:");

                numdays.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

                currCB.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

                jLabel88.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
                jLabel88.setText("Curriculum:");

                currTbl.setModel(new javax.swing.table.DefaultTableModel(
                    new Object [][] {

                    },
                    new String [] {
                        "Curriculums for this School Year"
                    }
                ) {
                    boolean[] canEdit = new boolean [] {
                        false
                    };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit [columnIndex];
                    }
                });
                jScrollPane3.setViewportView(currTbl);

                add1.setText("Add");
                add1.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        add1ActionPerformed(evt);
                    }
                });

                save1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
                save1.setText("Save");
                save1.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        save1ActionPerformed(evt);
                    }
                });

                cancel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
                cancel1.setText("Cancel");

                compute.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
                compute.setText("Compute");
                compute.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        computeActionPerformed(evt);
                    }
                });

                remove1.setText("Remove");
                remove1.setEnabled(false);
                remove1.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        remove1ActionPerformed(evt);
                    }
                });

                javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
                jPanel11.setLayout(jPanel11Layout);
                jPanel11Layout.setHorizontalGroup(
                    jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addComponent(remove1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(save1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cancel1))
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                            .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel11Layout.createSequentialGroup()
                                    .addComponent(jLabel5)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(startC, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel11Layout.createSequentialGroup()
                                    .addComponent(jLabel6)
                                    .addGap(18, 18, 18)
                                    .addComponent(endC, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel11Layout.createSequentialGroup()
                                    .addComponent(jLabel4)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(syCB, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel11Layout.createSequentialGroup()
                                    .addComponent(jLabel88)
                                    .addGap(4, 4, 4)
                                    .addComponent(currCB, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel11Layout.createSequentialGroup()
                                    .addGap(327, 327, 327)
                                    .addComponent(add1))
                                .addGroup(jPanel11Layout.createSequentialGroup()
                                    .addComponent(jLabel7)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(numdays, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(compute))))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                );
                jPanel11Layout.setVerticalGroup(
                    jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(syCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addGap(16, 16, 16)
                                .addComponent(jLabel5))
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(startC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(13, 13, 13)
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel6)
                            .addComponent(endC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(numdays, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(compute))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel88)
                            .addComponent(currCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(add1))
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addComponent(remove1)
                                .addContainerGap(25, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                                .addGap(0, 23, Short.MAX_VALUE)
                                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(cancel1)
                                    .addComponent(save1)))))
                );

                javax.swing.GroupLayout p1Layout = new javax.swing.GroupLayout(p1);
                p1.setLayout(p1Layout);
                p1Layout.setHorizontalGroup(
                    p1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p1Layout.createSequentialGroup()
                        .addGap(243, 243, 243)
                        .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(269, Short.MAX_VALUE))
                );
                p1Layout.setVerticalGroup(
                    p1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(85, Short.MAX_VALUE))
                );

                mainP.addTab("School Year", p1);

                jPanel12.setBackground(new java.awt.Color(255, 255, 255));
                jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List of Available Class Levels", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

                clevel1.setModel(new javax.swing.table.DefaultTableModel(
                    new Object [][] {

                    },
                    new String [] {
                        "Class Level", "Category"
                    }
                ) {
                    boolean[] canEdit = new boolean [] {
                        false, false
                    };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit [columnIndex];
                    }
                });
                jScrollPane1.setViewportView(clevel1);

                jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel2.setText("No. of Entries:");

                label2a.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                label2a.setText("000");

                jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel12.setText("Curriculum:");

                javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
                jPanel12.setLayout(jPanel12Layout);
                jPanel12Layout.setHorizontalGroup(
                    jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label2a)
                                .addGap(0, 245, Short.MAX_VALUE))
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(currCB2, 0, 287, Short.MAX_VALUE)))
                        .addContainerGap())
                );
                jPanel12Layout.setVerticalGroup(
                    jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(currCB2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(label2a)))
                );

                add2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                add2.setText("Add >>");
                add2.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        add2ActionPerformed(evt);
                    }
                });

                remove2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                remove2.setText("<< Remove");
                remove2.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        remove2ActionPerformed(evt);
                    }
                });

                addclevel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
                addclevel.setText("Add Class Level");
                addclevel.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        addclevelActionPerformed(evt);
                    }
                });

                save2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                save2.setText("Save");
                save2.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        save2ActionPerformed(evt);
                    }
                });

                cancel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                cancel2.setText("Cancel");
                cancel2.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        cancel2ActionPerformed(evt);
                    }
                });

                jPanel13.setBackground(new java.awt.Color(255, 255, 255));
                jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Chosen Class Levels", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

                clevel2.setModel(new javax.swing.table.DefaultTableModel(
                    new Object [][] {

                    },
                    new String [] {
                        "Class Level", "Category", "Curriculum"
                    }
                ) {
                    boolean[] canEdit = new boolean [] {
                        false, false, false
                    };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit [columnIndex];
                    }
                });
                clevel2.addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseClicked(java.awt.event.MouseEvent evt) {
                        clevel2MouseClicked(evt);
                    }
                });
                jScrollPane2.setViewportView(clevel2);

                jLabel13.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel13.setText("No. of Entries:");

                label2b.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                label2b.setText("000");

                javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
                jPanel13.setLayout(jPanel13Layout);
                jPanel13Layout.setHorizontalGroup(
                    jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                            .addGroup(jPanel13Layout.createSequentialGroup()
                                .addGap(254, 254, 254)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label2b)
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGap(10, 10, 10))
                );
                jPanel13Layout.setVerticalGroup(
                    jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(label2b)))
                );

                javax.swing.GroupLayout p2Layout = new javax.swing.GroupLayout(p2);
                p2.setLayout(p2Layout);
                p2Layout.setHorizontalGroup(
                    p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(p2Layout.createSequentialGroup()
                                .addComponent(addclevel, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(586, 586, 586)
                                .addComponent(save2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cancel2))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, p2Layout.createSequentialGroup()
                                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(remove2)
                                    .addComponent(add2, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(10, 10, 10)
                                .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addContainerGap(22, Short.MAX_VALUE))
                );
                p2Layout.setVerticalGroup(
                    p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p2Layout.createSequentialGroup()
                        .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, p2Layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(p2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(addclevel)
                                    .addComponent(save2)
                                    .addComponent(cancel2)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, p2Layout.createSequentialGroup()
                                .addGap(177, 177, 177)
                                .addComponent(add2, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(remove2, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(41, Short.MAX_VALUE))
                );

                mainP.addTab("Class Level", p2);

                jPanel14.setBackground(new java.awt.Color(255, 255, 255));
                jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List of Available Subjects", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

                sub1.setModel(new javax.swing.table.DefaultTableModel(
                    new Object [][] {

                    },
                    new String [] {
                        "Subject", "Description", "Units"
                    }
                ) {
                    boolean[] canEdit = new boolean [] {
                        false, false, false
                    };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit [columnIndex];
                    }
                });
                jScrollPane5.setViewportView(sub1);

                jLabel25.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel25.setText("No. of Entries:");

                label4a.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                label4a.setText("000");

                clevelCB3.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        clevelCB3ActionPerformed(evt);
                    }
                });

                jLabel40.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel40.setText("Class Level:");

                javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
                jPanel14.setLayout(jPanel14Layout);
                jPanel14Layout.setHorizontalGroup(
                    jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)
                            .addGroup(jPanel14Layout.createSequentialGroup()
                                .addComponent(jLabel25)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label4a)
                                .addGap(0, 245, Short.MAX_VALUE))
                            .addGroup(jPanel14Layout.createSequentialGroup()
                                .addComponent(jLabel40)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(clevelCB3, 0, 286, Short.MAX_VALUE)))
                        .addContainerGap())
                );
                jPanel14Layout.setVerticalGroup(
                    jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel40)
                            .addComponent(clevelCB3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel25)
                            .addComponent(label4a)))
                );

                add3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                add3.setText("Add >>");
                add3.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        add3ActionPerformed(evt);
                    }
                });

                remove3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                remove3.setText("<< Remove");
                remove3.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        remove3ActionPerformed(evt);
                    }
                });

                addsubj.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
                addsubj.setText("Add Subject");
                addsubj.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        addsubjActionPerformed(evt);
                    }
                });

                save3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                save3.setText("Save");
                save3.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        save3ActionPerformed(evt);
                    }
                });

                cancel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                cancel3.setText("Cancel");
                cancel3.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        cancel3ActionPerformed(evt);
                    }
                });

                jPanel15.setBackground(new java.awt.Color(255, 255, 255));
                jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Chosen Subjects", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

                sub2.setModel(new javax.swing.table.DefaultTableModel(
                    new Object [][] {

                    },
                    new String [] {
                        "Subject", "Description", "Units"
                    }
                ) {
                    boolean[] canEdit = new boolean [] {
                        false, false, false
                    };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit [columnIndex];
                    }
                });
                sub2.addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseClicked(java.awt.event.MouseEvent evt) {
                        sub2MouseClicked(evt);
                    }
                });
                jScrollPane9.setViewportView(sub2);

                jLabel28.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel28.setText("No. of Entries:");

                label4b.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                label4b.setText("000");

                javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
                jPanel15.setLayout(jPanel15Layout);
                jPanel15Layout.setHorizontalGroup(
                    jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                .addComponent(jLabel28)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label4b))
                            .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                );
                jPanel15Layout.setVerticalGroup(
                    jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel28)
                            .addComponent(label4b)))
                );

                javax.swing.GroupLayout p3Layout = new javax.swing.GroupLayout(p3);
                p3.setLayout(p3Layout);
                p3Layout.setHorizontalGroup(
                    p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(p3Layout.createSequentialGroup()
                                .addComponent(addsubj, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(586, 586, 586)
                                .addComponent(save3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cancel3))
                            .addGroup(p3Layout.createSequentialGroup()
                                .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(remove3)
                                    .addComponent(add3, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(10, 10, 10)
                                .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)))
                        .addContainerGap(26, Short.MAX_VALUE))
                );
                p3Layout.setVerticalGroup(
                    p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p3Layout.createSequentialGroup()
                        .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, p3Layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(p3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(addsubj)
                                    .addComponent(save3)
                                    .addComponent(cancel3)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, p3Layout.createSequentialGroup()
                                .addGap(177, 177, 177)
                                .addComponent(add3, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(remove3, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(39, Short.MAX_VALUE))
                );

                mainP.addTab("Subject", p3);

                jPanel7.setBackground(new java.awt.Color(255, 255, 255));
                jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Chosen Sections", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

                secT2.setModel(new javax.swing.table.DefaultTableModel(
                    new Object [][] {

                    },
                    new String [] {
                        "Sections", "Adviser"
                    }
                ) {
                    boolean[] canEdit = new boolean [] {
                        false, false
                    };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit [columnIndex];
                    }
                });
                secT2.addMouseListener(new java.awt.event.MouseAdapter() {
                    public void mouseClicked(java.awt.event.MouseEvent evt) {
                        secT2MouseClicked(evt);
                    }
                });
                jScrollPane6.setViewportView(secT2);

                jLabel22.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel22.setText("No. of Entries:");

                label5b.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                label5b.setText("000");

                javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
                jPanel7.setLayout(jPanel7Layout);
                jPanel7Layout.setHorizontalGroup(
                    jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel7Layout.createSequentialGroup()
                                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addComponent(jLabel22)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label5b)))
                        .addContainerGap())
                );
                jPanel7Layout.setVerticalGroup(
                    jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(label5b)))
                );

                add4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                add4.setText("Add >>");
                add4.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        add4ActionPerformed(evt);
                    }
                });

                remove4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                remove4.setText("<< Remove");
                remove4.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        remove4ActionPerformed(evt);
                    }
                });

                jPanel8.setBackground(new java.awt.Color(255, 255, 255));
                jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "List of Available Sections", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

                secT1.setModel(new javax.swing.table.DefaultTableModel(
                    new Object [][] {

                    },
                    new String [] {
                        "Sections"
                    }
                ) {
                    boolean[] canEdit = new boolean [] {
                        false
                    };

                    public boolean isCellEditable(int rowIndex, int columnIndex) {
                        return canEdit [columnIndex];
                    }
                });
                jScrollPane7.setViewportView(secT1);

                jLabel30.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel30.setText("No. of Entries:");

                label5a.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                label5a.setText("000");

                clevelCB4.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        clevelCB4ActionPerformed(evt);
                    }
                });

                jLabel33.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                jLabel33.setText("Class Level:");

                javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
                jPanel8.setLayout(jPanel8Layout);
                jPanel8Layout.setHorizontalGroup(
                    jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                                .addComponent(jLabel33)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(clevelCB4, 0, 285, Short.MAX_VALUE))
                            .addGroup(jPanel8Layout.createSequentialGroup()
                                .addComponent(jLabel30)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label5a)
                                .addGap(0, 244, Short.MAX_VALUE)))
                        .addContainerGap())
                );
                jPanel8Layout.setVerticalGroup(
                    jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel33)
                            .addComponent(clevelCB4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel30)
                            .addComponent(label5a)))
                );

                addsection.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
                addsection.setText("Add Section");
                addsection.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        addsectionActionPerformed(evt);
                    }
                });

                save4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                save4.setText("Save");
                save4.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        save4ActionPerformed(evt);
                    }
                });

                cancel4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
                cancel4.setText("Cancel");

                javax.swing.GroupLayout p4Layout = new javax.swing.GroupLayout(p4);
                p4.setLayout(p4Layout);
                p4Layout.setHorizontalGroup(
                    p4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(p4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(p4Layout.createSequentialGroup()
                                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(7, 7, 7)
                                .addGroup(p4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(remove4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(add4, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(p4Layout.createSequentialGroup()
                                .addComponent(addsection, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(save4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cancel4)))
                        .addContainerGap(22, Short.MAX_VALUE))
                );
                p4Layout.setVerticalGroup(
                    p4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(p4Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(p4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(p4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(addsection)
                            .addComponent(save4)
                            .addComponent(cancel4))
                        .addGap(77, 77, 77))
                    .addGroup(p4Layout.createSequentialGroup()
                        .addGap(192, 192, 192)
                        .addComponent(add4, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(remove4, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(232, Short.MAX_VALUE))
                );

                mainP.addTab("Section", p4);

                jSeparator2.setForeground(new java.awt.Color(0, 102, 51));

                javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                getContentPane().setLayout(layout);
                layout.setHorizontalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jSeparator1)
                                    .addComponent(mainP, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                                .addContainerGap())
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(dateL)
                                .addGap(53, 53, 53)
                                .addComponent(timeL)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(usernameL)
                                .addGap(18, 18, 18)
                                .addComponent(logoutB)
                                .addGap(33, 33, 33))))
                );
                layout.setVerticalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(dateL)
                            .addComponent(timeL)
                            .addComponent(usernameL)
                            .addComponent(logoutB))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(mainP, javax.swing.GroupLayout.PREFERRED_SIZE, 542, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                );

                pack();
            }// </editor-fold>//GEN-END:initComponents

    private void clevelCB4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clevelCB4ActionPerformed
        if(sss.equals("view")) {
            load3b();
        } else {
            load3a();
            secdtm2 = new DefaultTableModel(new String[]{secT2.getColumnName(0), secT2.getColumnName(1)}, 0);
            secT2.setModel(secdtm2);
            label5a.setText(sec1.size() + "");
            load3b();
        }
    }//GEN-LAST:event_clevelCB4ActionPerformed

    private void mainPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainPMouseClicked
        if (mainP.getSelectedIndex() == 0) {
            try {
                int previous;
                int start = mi.getToday();
                previous = Integer.valueOf(start);

                int next;
                String end = mi.getRealYear();
                next = Integer.valueOf(end);

                for (int x = previous; x < previous + 100; x++) {
                    for (int y = x + 1; y < previous + 100; y++) {
                        syCB.addItem(x + "-" + y);
                        x = y;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (mainP.getSelectedIndex() == 1) {
            if (sss.equals("open")) {
                try {
                    if (currCB2.getItemCount() == 0) {
                        add2.setEnabled(false);
                        remove2.setEnabled(false);
                        save2.setEnabled(false);
                        cancel2.setEnabled(false);
                    } else {
                        add2.setEnabled(true);
                        remove2.setEnabled(true);
                        save2.setEnabled(true);
                        cancel2.setEnabled(true);
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                currCB2.setEnabled(false);
                clevel1.setEnabled(false);
                add2.setEnabled(false);
                remove2.setEnabled(false);
                addclevel.setEnabled(false);
                save2.setEnabled(false);
            }
        } else if (mainP.getSelectedIndex() == 2) {
            if (sss.equals("open")) {
                try {
                    if (clevelCB3.getItemCount() == 0) {
                        add3.setEnabled(false);
                        remove3.setEnabled(false);
                        save3.setEnabled(false);
                        cancel3.setEnabled(false);
                    } else {
                        add3.setEnabled(true);
                        remove3.setEnabled(true);
                        save3.setEnabled(true);
                        cancel3.setEnabled(true);
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
//                clevelCB3.setEnabled(false);
                sub1.setEnabled(false);
                add3.setEnabled(false);
                remove3.setEnabled(false);
                addsubj.setEnabled(false);
                save3.setEnabled(false);
            }

        } else if (mainP.getSelectedIndex() == 3) {
            if (sss.equals("open")) {
                try {
                    if (clevelCB4.getItemCount() == 0) {
                        add4.setEnabled(false);
                        remove4.setEnabled(false);
                        save4.setEnabled(false);
                        cancel4.setEnabled(false);
                    } else {
                        add4.setEnabled(true);
                        remove4.setEnabled(true);
                        save4.setEnabled(true);
                        cancel4.setEnabled(true);
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
//                clevelCB4.setEnabled(false);
                add4.setEnabled(false);
                remove4.setEnabled(false);
                addsubj.setEnabled(false);
                save4.setEnabled(false);
            }

        }
    }//GEN-LAST:event_mainPMouseClicked

    private void add1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add1ActionPerformed
        Curriculum c = currList.get(currCB.getSelectedIndex());

        selected.add(c);

        currTbl.setModel(currdtm);
        currdtm.addRow(new Object[]{c.getCurrName()});

        currList.remove(c);
        loadCurrCB();

        remove1.setEnabled(true);

        if (currCB.getItemCount() == 0) {
            add1.setEnabled(false);
        }

        if (currTbl.getRowCount() == 2) {
            add1.setEnabled(false);
        }
    }//GEN-LAST:event_add1ActionPerformed

    private void save1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save1ActionPerformed
        try {
            boolean add = false;
            String startD = ((JTextField) startC.getDateEditor().getUiComponent()).getText();
            String endD = ((JTextField) endC.getDateEditor().getUiComponent()).getText();
            String sySelect = syCB.getSelectedItem().toString();

            if (startD.isEmpty() || endD.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Please fill out the needed fields", "Error", JOptionPane.ERROR_MESSAGE);
                label2a.setForeground(Color.red);
                jLabel4.setForeground(Color.red);
            } else if (startC.getDate().compareTo(endC.getDate()) > 0 || endC.getDate().compareTo(startC.getDate()) < 0) {
                JOptionPane.showMessageDialog(null, "Invalid Date", "Error", JOptionPane.ERROR_MESSAGE);
                label2a.setForeground(Color.red);
                jLabel4.setForeground(Color.red);
            } else if (numdays.getText().isEmpty()) {
                JOptionPane.showMessageDialog(null, "Please click compute button", "Error", JOptionPane.ERROR_MESSAGE);
                jLabel7.setForeground(Color.red);
            } else {
                boolean addA = false;
                add = mi.add("add-sy", new SchoolYear(sySelect, startD, endD, Integer.valueOf(numdays.getText())), "", cUser);
                SchoolYear syy = (SchoolYear) mi.get("get-sy", syCB.getSelectedItem().toString(), "");
                syID = syy.getSyID() + "";
                if (currTbl.getRowCount() == 2) {
                    boolean a1 = mi.add("add-currsy", new SchoolYear(0, Integer.valueOf(selected.get(0).getCurrID()), Integer.valueOf(syy.getSyID())), "", cUser);
                    boolean a2 = mi.add("add-currsy", new SchoolYear(0, Integer.valueOf(selected.get(1).getCurrID()), Integer.valueOf(syy.getSyID())), "", cUser);
                    if (a1 && a2) {
                        addA = true;
                    }
                } else {
                    addA = mi.add("add-currsy", new SchoolYear(0, Integer.valueOf(selected.get(0).getCurrID()), Integer.valueOf(syy.getSyID())), "", cUser);
                }
                if (addA && add) {
                    JOptionPane.showMessageDialog(null, "You have successfully opened a new school year.", "Success", JOptionPane.INFORMATION_MESSAGE);
                    save1.setEnabled(false);
                    remove1.setEnabled(false);
                    syCB.setEnabled(false);
                    p2.setEnabled(true);

                    currCB2.removeAllItems();
                    for (int x = 0; x < selected.size(); x++) {
                        currCB2.addItem(selected.get(x).getCurrName());
                    }

                    mainP.setSelectedIndex(1);
                    load1a();
                    cleveldtm2 = new DefaultTableModel(new String[]{clevel2.getColumnName(0), clevel2.getColumnName(1), clevel2.getColumnName(2)}, 0);
                    clevel2.setModel(cleveldtm2);
                    mainPMouseClicked(null);
                } else {
                    JOptionPane.showMessageDialog(null, "A Server/Database error has occurred!", "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_save1ActionPerformed

    private void add2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add2ActionPerformed
//        // TODO add your handling code here:
//        String sectionA = null;
//        ArrayList<String> rev = new ArrayList<String>();
//        
//        int[] sel = clevel1.getSelectedRows();
////        for(int i = 0; i < sel.length; i++) {
//        for(int i = sel.length - 1; i >= 0; i--) {
//            sectionA = (String) clevel1.getValueAt(sel[i], 0);
////            sectionA = (String) clTbl.getValueAt(clTbl.convertRowIndexToView(sel[i]), 0);
//            rev.add(sectionA);
//        }
//        
//        for(int x = rev.size() - 1; x >= 0; x-- ) {
////            dtmc.addRow(new Object[] {rev.get(x).toString(), jComboBox1.getSelectedItem().toString()});
////            dtm2.removeRow(sel[x]);
////            dtm2.removeRow(clTbl.convertRowIndexToView(sel[x]));
////            dtm2.fireTableDataChanged();            
//        }


//        if(clevel1.getRowCount() == 0) {
//            JOptionPane.showMessageDialog (null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
//        } else {
//            int[] rows = clevel1.getSelectedRows();
//            loadTbl2b(rows);
//            remStud1(rows);
//        }

        if (clevel1.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to add!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = clevel1.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = clevel1.getSelectedRows();
                add1b(rows);
                rem1a(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_add2ActionPerformed

    private void remove2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove2ActionPerformed
//        // TODO add your handling code here:
//        String sectionA = null;
//        String sectionB = null;
//        ArrayList<String> rev = new ArrayList<String>();
//        
//        int[] sel = clevel2.getSelectedRows();
//        for(int i = sel.length - 1; i >= 0; i--) {            
//            sectionA = (String) clevel2.getValueAt(sel[i], 0);
//            rev.add(sectionA);
//            sectionB = clevel2.getValueAt(sel[i], 1).toString();
//        }
////            if(!lst.contains(sectionA)) {                             
//                for(int x = rev.size() - 1; x >= 0; x-- ) {
////                    dtm2.addRow(new Object[] {rev.get(x).toString()});
//                    System.out.println(sel.length + " " + sel[x]);
////                    dtmc.removeRow(sel[x]);
//                    //dtm.removeRow(chosenClTbl.getSelectedRows()[sel[x]]);
////                    dtmc.fireTableDataChanged();
//                }
////            }

        if (clevel2.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to remove!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = clevel2.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = clevel2.getSelectedRows();
                add1a(rows);
                rem1b(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_remove2ActionPerformed

    private void addclevelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addclevelActionPerformed
//        new ClassLevel_Manage(cUser, mi, this, "Add", null).setVisible(true);
    }//GEN-LAST:event_addclevelActionPerformed

    private void save2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save2ActionPerformed
        boolean success = false;

        for (int x = 0; x < cl2.size(); x++) {
            try {
                ClassLevel cl = cl2.get(x);
                String currsy = (String) mi.get("get-currsyID", cl.getCurrID(), syID);
                String cclid = (String) mi.get("get-currclID", cl.getClassID(), currsy);
                System.out.println(cclid);
                if (cclid == null) {
                    System.out.println("re");
                    success = mi.add("add-currcl", new ClassLevel(Integer.valueOf(cl.getClassID()), Integer.valueOf(currsy)), "", cUser);
                } else {
                    success = true;
                }

            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

        if (success) {
            try {
                JOptionPane.showMessageDialog(null, "Class levels successfully added to the school year : " + syCB.getSelectedItem().toString(), "Success", JOptionPane.INFORMATION_MESSAGE);
                clevelsyList = (ArrayList<ClassLevel>) mi.getList2("getlist2-clevelsy", syID, "").clone();
                clevelCB3.removeAllItems();
                clevelCB4.removeAllItems();
                for (int x = 0; x < clevelsyList.size(); x++) {
                    System.out.println(clevelsyList.get(x).getClassName());
                    clevelCB3.addItem(clevelsyList.get(x).getClassName());
                    clevelCB4.addItem(clevelsyList.get(x).getClassName());
                }
                load2a();
                subjdtm2 = new DefaultTableModel(new String[]{sub2.getColumnName(0), sub2.getColumnName(1), sub2.getColumnName(2)}, 0);
                sub2.setModel(subjdtm2);
                load3a();
                secdtm2 = new DefaultTableModel(new String[]{secT2.getColumnName(0), secT2.getColumnName(1)}, 0);
                secT2.setModel(secdtm2);
                mainP.setSelectedIndex(2);
                mainPMouseClicked(null);
                p3.setEnabled(true);
                p4.setEnabled(true);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } else {
            JOptionPane.showMessageDialog(null, "A Server/Database error has occurred!", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_save2ActionPerformed

    private void computeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_computeActionPerformed
        compute();
    }//GEN-LAST:event_computeActionPerformed

    private void clevel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clevel2MouseClicked
        // TODO add your handling code here:
//        if(evt.getClickCount() == 2) {
//                int x1 = clevel2.getSelectedColumn();
//                while(x1 != 0) {
//                    x1--;
//                }
//                
//                int x2 = clevel2.getSelectedColumn();
//                while(x2 != 1) {
//                    x2++;
//                }
//                
//                int y = clevel2.getSelectedRow();
//                mcClevelTbl1.getCellRenderer(y, x);
//                cll = (String) chosenClTbl.getValueAt(y, x1);    
//                JOptionPane.showMessageDialog(null, cll);
//                cur = chosenClTbl.getValueAt(y, x2).toString();
//                if(lst.contains(cll)) {
//                    int p = JOptionPane.showConfirmDialog(null,"Are you sure you want to Change/Edit the Subject/s of this Class Level?","Alert!",JOptionPane.YES_NO_OPTION);        
//                        if(p == JOptionPane.YES_OPTION){
////                            this.setVisible(false);
////                            new CurriculumCSE_Manage(cUser, ccu, val, mi, lst, ck).setVisible(true);
////                              cll = chosenClTbl.getValueAt(chosenClTbl.getSelectedRow(), 0).toString();
//                              jTabbedPane1.setSelectedIndex(2);
//                              jLabel18.setText(cur);
//                              jLabel17.setText(cll);
//                              jLabel19.setText(jLabel15.getText());
//                              jTabbedPane1.repaint();
//                        }
//                }else {
////                    this.setVisible(false);
////                    new CurriculumCSE_Manage(cUser, ccu, val, mi, lst, ck).setVisible(true);
////                    cll = chosenClTbl.getValueAt(chosenClTbl.getSelectedRow(), 0).toString();a
//                    jTabbedPane1.setSelectedIndex(2);
//                    jLabel18.setText(cur);
//                    jLabel17.setText(cll);
//                    jLabel19.setText(jLabel15.getText());
//                    jTabbedPane1.repaint();
//                }
//            }        
    }//GEN-LAST:event_clevel2MouseClicked

    private void cancel2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cancel2ActionPerformed

    private void syCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_syCBActionPerformed
        try {
            currList = (ArrayList<Curriculum>) mi.getList2("getlist2-curriculumopensy", syCB.getSelectedItem().toString().split("-")[0], "").clone();
            loadCurrCB();
            currTbl.removeAll();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_syCBActionPerformed

    private void remove1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove1ActionPerformed
        currList.add(selected.get(currTbl.getSelectedRow()));
        add1.setEnabled(true);

        selected.remove(currTbl.getSelectedRow());
        currdtm.removeRow(currTbl.getSelectedRow());

        loadCurrCB();
        if (currTbl.getRowCount() == 0) {
            remove1.setEnabled(false);
        }
    }//GEN-LAST:event_remove1ActionPerformed

    private void add3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add3ActionPerformed
        if (sub1.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to add!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = sub1.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = sub1.getSelectedRows();
                add2b(rows);
                rem2a(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_add3ActionPerformed

    private void remove3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove3ActionPerformed
        if (sub2.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to remove!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = sub2.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = sub2.getSelectedRows();
                add2a(rows);
                rem2b(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_remove3ActionPerformed

    private void addsubjActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addsubjActionPerformed
//        new Subject_Manage(cUser, mi, clevelsyList, this, "Add", null).setVisible(true);
    }//GEN-LAST:event_addsubjActionPerformed

    private void save3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save3ActionPerformed
        boolean success = false;
        ArrayList<Subject> existing = null;
        try {
            existing = (ArrayList<Subject>) mi.getList2("getlist2-subjforclevel", clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID(), "").clone();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        for (int x = 0; x < subj2.size(); x++) {
            try {
                if (existing.size() != 0) {
                    for (int y = 0; y < existing.size(); y++) {
                        Subject s = subj2.get(x);
                        if (!existing.get(y).getsubID().equals(s.getsubID())) {
                            s.setCurrclID(clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID());
                            System.out.println(s.getsubID() + " " + s.getCurrclID());
                            success = mi.add("add-currcls", s, "", cUser);
                        }
                    }
                } else {
                    Subject s = subj2.get(x);
                    s.setCurrclID(clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID());
                    System.out.println(s.getsubID() + " " + s.getCurrclID());
                    success = mi.add("add-currcls", s, "", cUser);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

        if (success) {
            try {
                JOptionPane.showMessageDialog(null, "Subject/s successfully added to " + clevelCB3.getSelectedItem() + "\nat school year : " + syCB.getSelectedItem().toString(), "Success", JOptionPane.INFORMATION_MESSAGE);
                /*
                 * clevelsyList = (ArrayList<ClassLevel>)
                 * mi.getList2("getlist2-clevelsy", syID).clone();
                 * clevelCB3.removeAllItems(); for(int x = 0; x <
                 * clevelsyList.size(); x++) {
                 * System.out.println(clevelsyList.get(x).getClassName());
                 * clevelCB3.addItem(clevelsyList.get(x).getClassName()); }
                 * load2a(); mainP.setSelectedIndex(2);
                mainPMouseClicked(null);
                 */
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } else {
            JOptionPane.showMessageDialog(null, "A Server/Database error has occurred!", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_save3ActionPerformed

    private void cancel3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cancel3ActionPerformed

    private void sub2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_sub2MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_sub2MouseClicked

    private void logoutBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutBActionPerformed
        int x = JOptionPane.showConfirmDialog(null, "Are you sure you want to logout already?", "Alert!", JOptionPane.YES_NO_OPTION);
        if (x == JOptionPane.YES_OPTION) {
            try {
                mi.logout(cUser.getUsername());
                this.setVisible(false);
                new _Login().setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_logoutBActionPerformed

    private void mainPMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainPMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_mainPMouseEntered

    private void clevelCB3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clevelCB3ActionPerformed
        if(sss.equals("view")) {
            load2b();
        } else {
            load2a();
            label4a.setText(subj1.size() + "");
            load2b();
        }
    }//GEN-LAST:event_clevelCB3ActionPerformed

    private void add4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add4ActionPerformed
        if (secT1.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to add!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = secT1.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = secT1.getSelectedRows();
                add3b(rows);
                rem3a(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_add4ActionPerformed

    private void remove4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove4ActionPerformed
        if (secT2.getRowCount() == 0) {
            JOptionPane.showMessageDialog(null, "There is nothing to remove!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            int x = secT2.getSelectedRowCount();
            if (x >= 1) {
                int[] rows = secT2.getSelectedRows();
                add3a(rows);
                rem3b(rows);
            } else {
                JOptionPane.showMessageDialog(null, "No row selected!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_remove4ActionPerformed

    private void save4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save4ActionPerformed
        ArrayList<String> sss = new ArrayList<String>();
        for(int x = 0; x < secT2.getRowCount(); x++) {
            sss.add(secdtm2.getValueAt(x, 1).toString());
        }
        
        if(sss.contains("None")) {
            JOptionPane.showMessageDialog(null, "You have to assign an adviser to a section!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            boolean success = false;
            ArrayList<Sections> existing = null;
            try {
                existing = (ArrayList<Sections>) mi.getList2("getlist2-secforclevel", clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID(), "").clone();
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            for (int x = 0; x < sec2.size(); x++) {
                try {
                    if (existing.size() != 0) {
                        for (int y = 0; y < existing.size(); y++) {
                            Sections s = sec2.get(x);
                            if (!(existing.get(y).getSecID() + "").equals(s.getSecID() + "")) {
                                s.setCurrclID(Integer.valueOf(clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID()));
                                success = mi.add("add-currclsec", s, "", cUser);
                                System.out.println("exist " + existing.get(y).getSecID() + " s " + s.getSecID());
                            }
                        }
                    } else {
                        Sections s = sec2.get(x);
                        s.setCurrclID(Integer.valueOf(clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID()));
                        success = mi.add("add-currclsec", s, "", cUser);
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }

            if (success) {
                try {
                    JOptionPane.showMessageDialog(null, "Section/s successfully added to " + clevelCB4.getSelectedItem() + "\nat school year : " + syCB.getSelectedItem().toString(), "Success", JOptionPane.INFORMATION_MESSAGE);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "A Server/Database error has occurred!", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_save4ActionPerformed

    private void secT2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_secT2MouseClicked
        if (evt.getClickCount() == 2) {
            try {
                Sections sec = sec2.get(secT2.getSelectedRow());
                /*String currsecid = (String) mi.get("get-currclsecID", sec.getSecID() + "", sec.getCurrclID() + "");
                System.out.println("secid " + sec.getSecID() + " currclid " + sec.getCurrclID() + " cse " + currsecid);
                ClassLevel cl = clevelsyList.get(clevelCB4.getSelectedIndex());
                System.out.println("classID " + cl.getClassID());
                User advs = (User) mi.get("get-secadv", cl.getClassID(), sec.getCurrclID() + "");
                System.out.println(advs.getID() + " " + advs.getName());*/
                ClassLevel cl = clevelsyList.get(clevelCB4.getSelectedIndex());
//                new SelectAdviser(cUser, mi, sec, cl, secT2.getSelectedRow(), this).setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }//GEN-LAST:event_secT2MouseClicked

    private void addsectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addsectionActionPerformed
//        new Section_Manage(cUser, mi, clevelsyList, this, "Add", null).setVisible(true);
    }//GEN-LAST:event_addsectionActionPerformed

    public void loadTable() {
        if (mainP.getSelectedIndex() == 1) {
//            try {
//                for(int x = 0; x < chCurr.size(); x++) {
//                    jComboBox1.addItem(chCurr.get(x));
//                }
//    //            
//    //            classList = mi.getList("classlevels2");
//    //            cl = new ArrayList<ClassLevel>();
//    //            for(int x = 0; x < classList.size(); x++) {
//    //                cl.add((ClassLevel) classList.get(x));
//    //            }
//    //                         
//    //            dtm = new DefaultTableModel(new String[] {chosenClTbl.getColumnName(0)}, 0);
//    //            chosenClTbl.setModel(dtm);
//    //            for(int x = 0; x < cl.size(); x++) {
//    //                dtm.insertRow(x, new Object[] {cl.get(x).getClasslevel()});
//    //            }
//    //            
//    //            for(int c = 0; c < dtm.getRowCount(); c++) {
//    //                chkList.add(chosenClTbl.getValueAt(c, 0).toString());
//    //            }
//
//                dtm2 = new DefaultTableModel(new String[] {clTbl.getColumnName(0)}, 0);
//                clTbl.setModel(dtm2);
//
//                lvlList = mi.getList("classlevels");
//                ArrayList<ClassLevel> ls = new ArrayList<ClassLevel>();
//                for(int x = 0; x < lvlList.size(); x++) {
//                    ls.add((ClassLevel) lvlList.get(x));
//                }
//
//                String chk = null;
//                for(int x = 0; x < ls.size(); x++) {
//                    chk = ls.get(x).getClasslevel();
//                    if(!chkList.contains(chk)) {
//                        dtm2.addRow(new Object[] {ls.get(x).getClasslevel()});                
//                    }
//                } 
//            } catch(Exception e) {
//                e.printStackTrace();
//            }
        }
    }

    public void loadCurrSY(String a) {
        try {
            if (a.equals("add")) {
                ArrayList<String> listsy = (ArrayList<String>) mi.getList("getlist-sylist").clone();
                int previous = Integer.valueOf(mi.getToday());
                for (int x = previous; x < previous + 100; x++) {
                    for (int y = x + 1; y < previous + 100; y++) {
                        if (!listsy.contains(x + "-" + y)) {
                            syCB.addItem(x + "-" + y);
                        }
                        x = y;
                    }
                }
            } else {
                ArrayList<String> listsy = (ArrayList<String>) mi.getList("getlist-sylist").clone();
                for (int x = 0; x < listsy.size(); x++) {
                    syCB.addItem(listsy.get(x));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void loadCurrCB() {
        currCB.removeAllItems();
        try {
            for (int x = 0; x < currList.size(); x++) {
                currCB.addItem(currList.get(x).getCurrName());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void load1a() {
        try {
            clevelList = (ArrayList<ClassLevel>) mi.getList("getlist-classlevels").clone();
            cl1 = (ArrayList<ClassLevel>) clevelList.clone();
            cleveldtm1 = new DefaultTableModel(new String[]{clevel1.getColumnName(0), clevel1.getColumnName(1)}, 0);
            clevel1.setModel(cleveldtm1);

            ArrayList<ClassLevel> t = new ArrayList<ClassLevel>();
            for (int x = 0; x < cl1.size(); x++) {
                if (cl2.size() != 0) {
                    boolean e = false;
                    for (int y = 0; y < cl2.size(); y++) {
                        if (cl1.get(x).getClassName().equals(cl2.get(y).getClassName())) {
                            e = true;
                        }
                    }

                    if (!e) {
                        t.add(cl1.get(x));
                        cleveldtm1.addRow(new Object[]{cl1.get(x).getClassName(), cl1.get(x).getClassCategory()});
                    }
                } else {
                    cleveldtm1.addRow(new Object[]{cl1.get(x).getClassName(), cl1.get(x).getClassCategory()});
                }
            }

            if (cl2.size() != 0) {
                cl1 = (ArrayList<ClassLevel>) t.clone();
            }
            label2a.setText(cl1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void load1b() {
        try {
//            System.out.println("kkkppp " + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassName());
            ArrayList<ClassLevel> clevels = (ArrayList<ClassLevel>) mi.getList2("getlist2-clevelcurrView", syCB.getSelectedItem().toString(), "").clone();
            cleveldtm2 = new DefaultTableModel(new String[]{clevel2.getColumnName(0), clevel2.getColumnName(1), clevel2.getColumnName(2)}, 0);
            clevel2.setModel(cleveldtm2);
            for (int y = 0; y < clevels.size(); y++) {
                ClassLevel c = clevels.get(y);
                cleveldtm2.addRow(new Object[]{c.getClassName(), c.getClassCategory(), c.getCurriculum()});

                label2b.setText(cl2.size() + "");
            }
            clevelsyList = (ArrayList<ClassLevel>) clevels.clone();
            for (int x = 0; x < clevelsyList.size(); x++) {
                clevelCB3.addItem(clevelsyList.get(x).getClassName());
                clevelCB4.addItem(clevelsyList.get(x).getClassName());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void add1a(int[] arr) {
        for (int x = 0; x < arr.length; x++) {
            ClassLevel s = cl2.get(arr[x]);
            cl1.add(s);
            cleveldtm1.addRow(new Object[]{s.getClassName(), s.getClassCategory()});
        }
        label2a.setText(cl1.size() + "");
    }

    public void add1b(int[] arr) {
        for (int x = 0; x < arr.length; x++) {
            ClassLevel c = cl1.get(arr[x]);
            for (int y = 0; y < clevelList.size(); y++) {
                if (clevelList.get(y).getClassName().equals(c.getClassName())) {
                    c.setClassID(clevelList.get(y).getClassID());
                }
            }

            c.setCurriculum(currCB2.getSelectedItem() + "");
            c.setCurrID(selected.get(currCB2.getSelectedIndex()).getCurrID());
            cl2.add(c);
            cleveldtm2.addRow(new Object[]{c.getClassName(), c.getClassCategory(), c.getCurriculum()});
        }
        label2b.setText(cl2.size() + "");
    }

    public void rem1a(int[] ii) {
        ArrayList<ClassLevel> clevel = (ArrayList<ClassLevel>) cl1.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            clevel.remove(ii[x]);
        }

        cl1 = (ArrayList<ClassLevel>) clevel.clone();
        try {
            cleveldtm1 = new DefaultTableModel(new String[]{clevel1.getColumnName(0), clevel1.getColumnName(1)}, 0);
            clevel1.setModel(cleveldtm1);
            for (int x = 0; x < cl1.size(); x++) {
                ClassLevel s = cl1.get(x);
                cleveldtm1.addRow(new Object[]{s.getClassName(), s.getClassCategory()});
            }
            label2a.setText(cl1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void rem1b(int[] ii) {
        ArrayList<ClassLevel> clevel = (ArrayList<ClassLevel>) cl2.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            clevel.remove(ii[x]);
        }

        cl2 = (ArrayList<ClassLevel>) clevel.clone();
        try {
            cleveldtm2 = new DefaultTableModel(new String[]{clevel2.getColumnName(0), clevel2.getColumnName(1), clevel2.getColumnName(2)}, 0);
            clevel2.setModel(cleveldtm2);
            for (int x = 0; x < cl2.size(); x++) {
                ClassLevel s = cl2.get(x);
                cleveldtm2.addRow(new Object[]{s.getClassName(), s.getClassCategory(), s.getCurriculum()});
            }
            label2b.setText(cl2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void load2a() {
        try {
//            System.out.println("kkk " + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassName());
            subjList = (ArrayList<Subject>) mi.getList2("getlist2-clsubjList", clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID(), clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID()).clone();
            subj1 = (ArrayList<Subject>) subjList.clone();
            subjdtm1 = new DefaultTableModel(new String[]{sub1.getColumnName(0), sub1.getColumnName(1), sub2.getColumnName(2)}, 0);
            sub1.setModel(subjdtm1);

            ArrayList<Subject> t = new ArrayList<Subject>();
            for (int x = 0; x < subj1.size(); x++) {
                Subject s = subj1.get(x);
                if (s.getUnits().equals("0")) {
                    s.setUnits("None");
                }
                if (subj2.size() != 0) {
                    boolean e = false;
                    for (int y = 0; y < subj2.size(); y++) {
                        if (subj1.get(x).getSubjName().equals(subj2.get(y).getSubjName())) {
                            e = true;
                        }
                    }

                    if (!e) {
                        t.add(s);
                        subjdtm1.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
                    }
                } else {
                    subjdtm1.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
                }
            }
            if (subj2.size() != 0) {
                subj1 = (ArrayList<Subject>) t.clone();
            }
            label4a.setText(subj1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void load2b() {
        try {
//            System.out.println("kkkppp " + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB3.getSelectedIndex()).getClassName());
//            if(sss.equals("view")) {
//                subj2 = (ArrayList<Subject>) mi.getList2("getlist2-clsubjList", clevelsyList.get(clevelCB3.getSelectedIndex()).getClassID(), clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID()).clone();
//            } else {
                subj2 = (ArrayList<Subject>) mi.getList2("getlist2-subjforclevel", clevelsyList.get(clevelCB3.getSelectedIndex()).getCurrclID(), "").clone();
            
//            }
            subjdtm2 = new DefaultTableModel(new String[]{sub2.getColumnName(0), sub2.getColumnName(1), sub2.getColumnName(2)}, 0);
            sub2.setModel(subjdtm2);
            if (subj2.size() != 0) {
                for (int x = 0; x < subj2.size(); x++) {
                    Subject s = subj2.get(x);
                    if (s.getUnits().equals("0")) {
                        s.setUnits("None");
                    }
                    subjdtm2.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
                }
            }
            label4b.setText(subj2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void add2a(int[] arr) {
        System.out.println("arr " + arr.length);
        for (int x = 0; x < arr.length; x++) {
            Subject s = subj2.get(arr[x]);
            subj1.add(s);
            subjdtm1.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
        }
        label4a.setText(subj1.size() + "");
    }

    public void add2b(int[] arr) {
        for (int x = 0; x < arr.length; x++) {
            Subject s = subj1.get(arr[x]);
            subj2.add(s);
            subjdtm2.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
        }
        label4b.setText(subj2.size() + "");
    }

    public void rem2a(int[] ii) {
        ArrayList<Subject> subj = (ArrayList<Subject>) subj1.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            subj.remove(ii[x]);
        }

        subj1 = (ArrayList<Subject>) subj.clone();
        try {
            subjdtm1 = new DefaultTableModel(new String[]{sub1.getColumnName(0), sub1.getColumnName(1), sub1.getColumnName(2)}, 0);
            sub1.setModel(subjdtm1);
            for (int x = 0; x < subj1.size(); x++) {
                Subject s = subj1.get(x);
                subjdtm1.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
            }
            label4a.setText(subj1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void rem2b(int[] ii) {
        ArrayList<Subject> subj = (ArrayList<Subject>) subj2.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            subj.remove(ii[x]);
        }

        subj2 = (ArrayList<Subject>) subj.clone();
        try {
            subjdtm2 = new DefaultTableModel(new String[]{sub2.getColumnName(0), sub2.getColumnName(1), sub2.getColumnName(2)}, 0);
            sub2.setModel(subjdtm2);
            for (int x = 0; x < subj2.size(); x++) {
                Subject s = subj2.get(x);
                subjdtm2.addRow(new Object[]{s.getSubjName(), s.getDesc(), s.getUnits()});
            }
            label4b.setText(subj2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void load3a() {
        try {
//            System.out.println("kkk " + clevelsyList.get(clevelCB4.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB4.getSelectedIndex()).getClassName());
            secList = (ArrayList<Sections>) mi.getList2("getlist2-clsecList", clevelsyList.get(clevelCB4.getSelectedIndex()).getClassID(), clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID()).clone();
            sec1 = (ArrayList<Sections>) secList.clone();
            secdtm1 = new DefaultTableModel(new String[]{secT1.getColumnName(0)}, 0);
            secT1.setModel(secdtm1);

            ArrayList<Sections> t = new ArrayList<Sections>();
            for (int x = 0; x < sec1.size(); x++) {
                Sections s = sec1.get(x);
                if (sec2.size() != 0) {
                    boolean e = false;
                    for (int y = 0; y < sec2.size(); y++) {
                        if (sec2.get(x).getSect().equals(sec2.get(y).getSect())) {
                            e = true;
                        }
                    }

                    if (!e) {
                        t.add(s);
                        secdtm1.addRow(new Object[]{s.getSect()});
                    }
                } else {
                    secdtm1.addRow(new Object[]{s.getSect()});
                }
            }
            if (sec2.size() != 0) {
                sec1 = (ArrayList<Sections>) t.clone();
            }
            label5a.setText(sec1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void load3b() {
        try {
//            System.out.println("kkkppp " + clevelsyList.get(clevelCB4.getSelectedIndex()).getClassID() + clevelsyList.get(clevelCB4.getSelectedIndex()).getClassName());
//            if(!sss.equals("view")) {
                sec2 = (ArrayList<Sections>) mi.getList2("getlist2-secforclevel", clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID(), "").clone();
//            } else {
//                sec2 = (ArrayList<Sections>) mi.getList2("getlist2-clsecList", clevelsyList.get(clevelCB4.getSelectedIndex()).getClassID(), clevelsyList.get(clevelCB4.getSelectedIndex()).getCurrclID()).clone();
//            }
            secdtm2 = new DefaultTableModel(new String[]{secT2.getColumnName(0), secT2.getColumnName(1)}, 0);
            secT2.setModel(secdtm2);
            if (sec2.size() != 0) {
                for (int x = 0; x < sec2.size(); x++) {
                    Sections s = sec2.get(x);
                    if(s.getAdv() == null) {
                        secdtm2.addRow(new Object[]{s.getSect(), "None"});
                    } else {
                        secdtm2.addRow(new Object[]{s.getSect(), s.getAdv().getName()});
                    }
                    
                }
            }
            label5b.setText(sec2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void add3a(int[] arr) {
        System.out.println("arr " + arr.length);
        for (int x = 0; x < arr.length; x++) {
            Sections s = sec2.get(arr[x]);
            sec1.add(s);
            secdtm1.addRow(new Object[]{s.getSect()});
        }
        label5a.setText(sec2.size() + "");
    }

    public void add3b(int[] arr) {
        for (int x = 0; x < arr.length; x++) {
            try {
                Sections s = sec1.get(arr[x]);
                User secadv = (User) mi.get("get-secadv", s.getSecID() + "", s.getCurrclID() + "");
                if (secadv == null) {
                    s.setAdv(null);
                    secdtm2.addRow(new Object[]{s.getSect(), "None"});
                } else {
                    s.setAdv(secadv);
                    secdtm2.addRow(new Object[]{s.getSect(), s.getAdv().getName()});
                }
                sec2.add(s);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        label5b.setText(sec2.size() + "");
    }

    public void rem3a(int[] ii) {
        ArrayList<Sections> se = (ArrayList<Sections>) sec1.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            se.remove(ii[x]);
        }

        sec1 = (ArrayList<Sections>) se.clone();
        try {
            secdtm1 = new DefaultTableModel(new String[]{secT1.getColumnName(0)}, 0);
            secT1.setModel(secdtm1);
            for (int x = 0; x < sec1.size(); x++) {
                Sections s = sec1.get(x);
                secdtm1.addRow(new Object[]{s.getSect()});
            }
            label5a.setText(sec1.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void rem3b(int[] ii) {
        ArrayList<Sections> se = (ArrayList<Sections>) sec2.clone();
        int j = ii.length - 1;
        for (int u = 0; u < j; u++, j--) {
            int t = ii[u];
            ii[u] = ii[j];
            ii[j] = t;
        }
        for (int x = 0; x < ii.length; x++) {
            se.remove(ii[x]);
        }

        sec2 = (ArrayList<Sections>) se.clone();
        try {
            secdtm2 = new DefaultTableModel(new String[]{secT2.getColumnName(0)}, 0);
            secT2.setModel(secdtm2);
            for (int x = 0; x < sec2.size(); x++) {
                Sections s = sec2.get(x);
                if(s.getAdv() == null) {
                    secdtm2.addRow(new Object[]{s.getSect(), "None"});
                } else {
                    secdtm2.addRow(new Object[]{s.getSect(), s.getAdv().getName()});
                }
            }
            label5b.setText(sec2.size() + "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void setAdviser(int index, User u) {
        Sections s = sec2.get(index);
        s.setAdv(u);
        if(s.getAdv() == null) {
            secdtm2.setValueAt("None", index, 1);
        } else {
            secdtm2.setValueAt(u.getName(), index, 1);
        }
    }
    
    public ArrayList<String> getAdvisers() {
        ArrayList<String> a = new ArrayList<String>();
        for(int x = 0; x < secT2.getRowCount(); x++) {
            String s = secdtm2.getValueAt(x, 1).toString();
            if(!s.equals("None")) {
                a.add(s);
                System.out.println("get " + s);
            }
        }
        return a;
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(_UAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(_UAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(_UAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(_UAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CurrDetails1(cUser, mi, sss, curr).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton add1;
    private javax.swing.JButton add2;
    private javax.swing.JButton add3;
    private javax.swing.JButton add4;
    private javax.swing.JButton addclevel;
    private javax.swing.JButton addsection;
    private javax.swing.JButton addsubj;
    private javax.swing.JButton cancel1;
    private javax.swing.JButton cancel2;
    private javax.swing.JButton cancel3;
    private javax.swing.JButton cancel4;
    private javax.swing.JTable clevel1;
    private javax.swing.JTable clevel2;
    private javax.swing.JComboBox clevelCB3;
    private javax.swing.JComboBox clevelCB4;
    private javax.swing.JButton compute;
    private javax.swing.JComboBox currCB;
    private javax.swing.JComboBox currCB2;
    private javax.swing.JTable currTbl;
    private javax.swing.JLabel dateL;
    private com.toedter.calendar.JDateChooser endC;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel88;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JLabel label2a;
    private javax.swing.JLabel label2b;
    private javax.swing.JLabel label4a;
    private javax.swing.JLabel label4b;
    private javax.swing.JLabel label5a;
    private javax.swing.JLabel label5b;
    private javax.swing.JButton logoutB;
    private javax.swing.JTabbedPane mainP;
    private javax.swing.JTextField numdays;
    private javax.swing.JPanel p1;
    private javax.swing.JPanel p2;
    private javax.swing.JPanel p3;
    private javax.swing.JPanel p4;
    private javax.swing.JButton remove1;
    private javax.swing.JButton remove2;
    private javax.swing.JButton remove3;
    private javax.swing.JButton remove4;
    private javax.swing.JButton save1;
    private javax.swing.JButton save2;
    private javax.swing.JButton save3;
    private javax.swing.JButton save4;
    private javax.swing.JTable secT1;
    private javax.swing.JTable secT2;
    private com.toedter.calendar.JDateChooser startC;
    private javax.swing.JTable sub1;
    private javax.swing.JTable sub2;
    private javax.swing.JComboBox syCB;
    private javax.swing.JLabel timeL;
    private javax.swing.JLabel usernameL;
    // End of variables declaration//GEN-END:variables
}
